package com.example.myapplication;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.myapplication.activity.HomeActivity;
import com.example.myapplication.activity.MainActivity2;
import com.example.myapplication.activity.ShapActivity;
import com.example.myapplication.activity.VHomeActivity;
import com.example.myapplication.bases.BaseActivity;

public class MainActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button bt = findViewById(R.id.bt);
        Button bt1 = findViewById(R.id.bt1);
        Button bt2 = findViewById(R.id.bt2);
        Button bt_shape=findViewById(R.id.bt_shape);
        Button bt_vhome=findViewById(R.id.bt_vhome);

        bt.setOnClickListener(clickListener);
        bt1.setOnClickListener(clickListener);
        bt2.setOnClickListener(clickListener);
        bt_shape.setOnClickListener(clickListener);
        bt_vhome.setOnClickListener(clickListener);

    }
     private  View.OnClickListener clickListener=new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (view.getId()==R.id.bt){
                    Intent intent=new Intent();
                    intent.setClass(MainActivity.this, MainActivity2.class);
                    startActivity(intent);
                }else if (view.getId()==R.id.bt1){
                    //隐式Intent的
                    Intent intent=new Intent(Intent.ACTION_SENDTO);
                    intent.setData(Uri.parse("smsto:10086")); // smsto 表示短信
                    intent.putExtra("sms_body", "Hello!");    // 短信内容
                    startActivity(intent);
                }else if (view.getId()==R.id.bt2){
                    //显式Intent
                    Intent intent=new Intent();
                    intent.setClass(MainActivity.this, HomeActivity.class);
                    startActivity(intent);
                }else if (view.getId()==R.id.bt_shape){
                    Intent intent=new Intent();
                    intent.setClass(MainActivity.this, ShapActivity.class);
                    startActivity(intent);
                }else if (view.getId()==R.id.bt_vhome) {
                    Intent intent = new Intent();
                    intent.setClass(MainActivity.this, VHomeActivity.class);
                    startActivity(intent);
                }
            }
        };

}